# %% 导入工具包

from pyomo.environ import *
from pyomo.opt import SolverFactory

# %% 创建规划模型

model = ConcreteModel()

# %% 声明规划变量

model.I = RangeSet(1, 3)
model.x = Var(model.I, domain=NonNegativeIntegers)

# %% 声明目标函数

model.obj = Objective(
    expr=( # x1 x2 + 2( x1 x3 + x2 x3 )
        (
            model.x[1]*model.x[2]
            ) + (
            2*(model.x[1]*model.x[3] + model.x[2]*model.x[3])
        )))

# %% 声明约束条件
model.con_1 = Constraint(
    expr=(
        model.x[1] * model.x[2] * model.x[3] == 300
    ))
model.con_2 = Constraint(
    expr=(
        model.x[1] >= 1
    ))

# %% 选择求解器为 SCIP 求解规划模型

opt = SolverFactory('scip')
results = opt.solve(model)


# %% 输出结果

print(results)
model.pprint()